<?xml version="1.0" encoding="UTF-8" ?>
<%@ page import="java.util.Collection" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script language="javascript">

/*function*/
function addInput(divName){
     	
		  var newdiv = document.createElement('div');
	      newdiv.innerHTML = "<br>nuova abilità: " + "&nbsp; <input type='text' maxlength='50' name='abSuppl' id='abSuppl' >" + "<div id='button'><input type='button' name='eliAb' id='submit' value='elimina' onclick='deleteNewElement(this)'/></div>";
          document.getElementById(divName).appendChild(newdiv);
         
     }

function deleteNewElement(n){
	n.parentNode.parentNode.parentNode.removeChild(n.parentNode.parentNode);
}

</script> 


<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagina di registrazione</title>
<link rel="stylesheet" type="text/css" href="scheletro.css">
</head>
<body>
<div id="container">
<table class="topHome">
	<tr>
		    <td id="logoHome">
	<a href="home.jsp">Swim v2</a>
	<br><br><b> A help with a click!</b>
	
	
		    </td>
			<td class="personal">
				
		
				<form action="Login" method="post" onsubmit="return check()">
						<b>Username:</b> <input type="text"  name="username" id="username">
				
						<b>Password:</b> <input type="password" name="password" id="password">
						
						<input id="button" type="submit" name="Login" value="login">
						<br><br>
						<b>Sei un nuovo utente?</b>&nbsp;<a href="Registrazione">Registrati</a>
				</form>
		
			</td>
	</tr>
</table>

<%String messaggio = (String) request.getAttribute("messaggio");
	if(messaggio != null) {
				out.println("<p class='errorMessage'>" + messaggio + "</p>");
		} %>

<br></br>


<div id="form">
<form action="Registrazione" method="post" id="form_register"  enctype="multipart/form-data" > 
   
   	<div id="titlePage"><h1>Registrazione nuovo utente</h1></div><br><br>
    <fieldset>
        <legend>Inserisci i tuoi dati</legend>
        
        
        	
        	  <table id="table_register">
        	 	<tr>
	        	 	<td>
			                <label for="nome">Nome*</label>
			                <input type="text" name="nome" maxlenght="15" id="nome" <%String nome = (String) request.getAttribute("nome");
								if(nome != null) {out.println("value=\""+nome+"\"");
							} %>>
			                
	                </td><td>
			        		<label for="cognome">Cognome*</label>
			                <input type="text" name="cognome" maxlength="15" id="cognome" <%String cognome = (String) request.getAttribute("cognome");
								if(cognome != null) {out.println("value=\""+cognome+"\"");
							} %>/>
	                </td>
	            </tr><tr>
	                <td>
			                <label for="email">Email*</label>
			              	<input type="text" name="email" maxlength="50" id="email" <%String email = (String) request.getAttribute("email");
								if(email != null) {out.println("value=\""+email+"\"");
							} %>/>
	          		</td><td>
			          		<label for="username">Username*</label>
			                <input type="text" name="username" maxlength="25" id="username" <%String username = (String) request.getAttribute("username");
								if(username != null) {out.println("value=\""+username+"\"");
							} %>/>
	            	</td>
	            </tr><tr>
	            	<td>               
			                <label for="password">Password*</label>
			                <input type="password" maxlength="20" name="password1" id="password1" />
			        </td><td>        
			                 <label for="password">Conferma* </label>
			                <input type="password" name="password2" maxlength="20" id="password2" />
            		</td>
            	</tr>
              
    			<tr>
    				<td>
                
	                <label for="titolo">Regione d'Italia</label>
	                <select name="regione" id="regione">
	                	<option value="">-All-</option>
	                	<option value="Abruzzo">Abruzzo</option>
	                	<option value="Basilicata">Basilicata</option>
	                	<option value="Calabria">Calabria</option>
	                	<option value="Campania">Campania</option>
	                	<option value="Emilia Romagna">Emilia Romagna</option>
	                	<option value="Friuli-Venezia-Giulia">Friuli-Venezia-Giulia</option>
	                	<option value="Lazio">Lazio</option>
	                	<option value="Liguria">Liguria</option>
	                	<option value="Lombardia">Lombardia</option>
	                	<option value="Marche">Marche</option>
	                	<option value="Molise">Molise</option>
	                	<option value="Piemonte">Piemonte</option>
	                	<option value="Puglia">Puglia</option>
	                	<option value="Sardegna">Sardegna</option>
	                	<option value="Sicilia">Sicilia</option>
	                	<option value="Toscana">Toscana</option>
	                	<option value="Trentino Alto-Adige">Trentino Alto-Adige</option>
	                	<option value="Umbria">Umbria</option>
	                	<option value="Valle d'Aosta">Valle d'Aosta</option>
	                	<option value="Veneto">Veneto</option>
	                </select> 
             	</td>
             
             </table> 
          </fieldset> 
         		<br><br><br>
                
                <fieldset>
   					             
                    <legend>Abilità</legend>
					<%
					@SuppressWarnings("unchecked")
					Collection<String> listAb= (Collection<String>) request.getAttribute("listAb");		
					if(listAb.size()>0) {
						%>
					<table align="center" cellpadding="8">
					<%
						int i=0;
						for(String s: listAb) {
							if(i==0){	
						%>
	                  <tr>
	                   	<td>  
		                    <label for="ab"><% out.print(s);%></label>
		                    <input type="checkbox" name="ab" id="ab" value="<% out.print(s); %>"/>
						</td>            	  
	                  	<%
	                  		i++;
							} else if(i==3){ %>
	                 	<td>  
		                    <label for="ab"><% out.print(s);%></label>
		                    <input type="checkbox" name="ab" id="ab" value="<% out.print(s); %>"/>
						</td>  
	                  </tr>
                		
                	<% i=0; }
							else { i++; %>
						<td>  
		                    <label for="ab"><% out.print(s);%></label>
		                    <input type="checkbox" name="ab" id="ab" value="<% out.print(s); %>"/>
						</td>	
								
					<%		}
						}	
						%>
						</table>
					<% }%>
                </fieldset>
          
            
        	            	<br><br>

               <div id="addAb">
               <b>Vuoi aggiungere altre abilità? :</b> 
                
                 <div id="button"><input type="button" name="addAb" id="submit" value="+" onclick="addInput('addAb');"/></div> <br><br>
            	
				</div>
				<br>
				<label for="foto">Inserisci foto:</label>
               		<input type="file" name="inputFoto" id="inputFoto" accept="image/jpeg"/><br><br>
        		<br><br><b>(* campi obbligatori)</b><br><br>
        		
                <input id="button" type="submit" name="submit" value="Registrati" />
            
        
     
   
	</form>
</div>


</div>
</body>
</html>